home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -in_the_mag- / reader_requests / scilab / doc / intro / macros / dpend.sci next >
Text File  |  1999-09-16  |  669b  |  25 lines

  1. function [zdot]=dpend(time,z)
  2.    th1=z(1);th2=z(2);th1d=z(3);th2d=z(4);
  3.    s12=sin(th1-th2);c12=cos(th1-th2);
  4.    m12=m1+m2;s1=sin(th1);s2=sin(th2);
  5.    mat=[m12*r1 m2*r2*c12;...
  6.         r1*c12 r2];
  7.    vec=-[m12*g*s1+m2*r2*th2d*th2d*s12;...
  8.          g*s2-r1*th1d*th1d*s12];
  9.    res=mat\vec;
  10.    th1dd=res(1);th2dd=res(2);
  11.    zdot=[th1d;th2d;th1dd;th2dd];
  12. //end
  13.  
  14. function []=pp(z)
  15.    th1=z(1,:);th2=z(2,:);
  16.    rc1=r1*cos(th1);rc2=r2*cos(th2);
  17.    rs1=r1*sin(th1);rs2=r2*sin(th2);
  18.    rs12=rs1+rs2;rc12=rc1+rc2;
  19.    rect=[-2.1,-3.1,2.1,1.1];
  20.    for k=1:maxi(size(th1));
  21.       plot2d([0 rs1(k) rs12(k)]',-[0 rc1(k) rc12(k)]',...
  22.         [-1],"011",' ',rect,[10,3,10,3]);
  23.    end,
  24. //end
  25.